/**
*      author: Y_Yao
*      created: 2025-03-20 20:36:18
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 12 + 3;
int n,m;
vector<vector<int>> ans;
vector<int> cur;
void dfs(int x,int step)
{
    if(cur.size() == n)
    {
        ans.push_back(cur);
        return;
    }

    for(int i = x;i + (n - step) * 10 <= m;i++)
    {
        cur.push_back(i);
        dfs(i + 10,step+1);
        cur.pop_back();
    }
}

void solve()
{
    cin >> n >> m;
    dfs(1,1);
    cout << ans.size() << endl;
    for(auto& e : ans)
    {
        for(auto& x : e)
        {
            cout << x << " ";
        }
        cout << endl;
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}